home *** CD-ROM | disk | FTP | other *** search
/ Symantec Visual Cafe for Java 2.5 / symantec-visual-cafe-2.5-database-dev-edition.iso / Visual Cafe Pro v1.0 / SOURCE.BIN / DialogBox.java < prev    next >
Encoding:
Java Source  |  1997-06-19  |  1.2 KB  |  50 lines

  1. package symantec.itools.awt.util.dialog;
  2.  
  3. import java.awt.Button;
  4. import java.awt.Event;
  5. import java.awt.Frame;
  6. import java.awt.Dialog;
  7. import java.awt.Rectangle;
  8.  
  9. public class DialogBox extends Dialog {
  10.  
  11.     protected Button okButton;
  12.  
  13.     public DialogBox(Frame f) {
  14.         this(f, false);
  15.     }
  16.  
  17.     public DialogBox(Frame f, boolean modal) {
  18.         this(f, "", modal);
  19.     }
  20.  
  21.     public DialogBox(Frame f, String s, boolean modal) {
  22.         super(f, s, modal);
  23.         setResizable(false);
  24.     }
  25.  
  26.     public synchronized void show() {
  27.         Rectangle bounds = getParent().bounds();
  28.         Rectangle abounds = bounds();
  29.  
  30.         move(bounds.x + (bounds.width - abounds.width) / 2,
  31.              bounds.y + (bounds.height - abounds.height) /2);
  32.  
  33.         super.show();
  34.     }
  35.  
  36.     protected void closeDialog() {
  37.         hide();
  38.         dispose();
  39.     }
  40.  
  41.     public boolean handleEvent(Event event) {
  42.         if ((event.target == okButton && event.id == Event.ACTION_EVENT) ||
  43.             (event.target == this && event.id == Event.WINDOW_DESTROY))
  44.             closeDialog();
  45.  
  46.         return super.handleEvent(event);
  47.     }
  48.  
  49. }
  50.